package com.kucowka.db.service;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.kucowka.db.dao.UserDao;
import com.kucowka.db.entities.User;

@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
@Service(value="UserService")
public class UserServiceImpl implements UserService {
	
	private static final Logger logger = Logger.getLogger(UserServiceImpl.class);
	
	private UserDao userDao;
	
	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public List<User> listAllUsers() {
		System.out.println("Returning existing users...");
		logger.debug("Returning existing users...");
		return userDao.getUsers();
	}

	@Transactional(readOnly = false)
	public void createUser(User user) {
		System.out.println("Creating new user...");
		userDao.createUser(user);
	}

	@Transactional(readOnly = false)
	public void removeUser(int id) {
		userDao.removeUser(id);
	}
	
	public String getServiceDescription(Long i, String s) {
		return "franek";
	}

}
